<div id="div_departement" class="row-fluid">

    <div class="span12">

        <div class="box gradient">

            <div class="title">
                <h4>
                    <span>List Département</span>
                </h4>
            </div>
            <div id="div-list-user" class="content noPad clearfix">
                <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper" role="grid">
                    <div id="DataTables_Table_0_filter" class="dataTables_filter">
                        <table>
                            <tr>
                                <td>
                                    <label>
                                        Nom :
                                        <input class="text" type="text" id="filtre_nom" aria-controls="DataTables_Table_0"/>
                                    </label>
                                </td>
                                <td>
                                    <label>
                                        Ville :
                                        <input class="text" type="text" id="filtre_ville" aria-controls="DataTables_Table_0"/>
                                    </label>
                                </td>
                                <td>
                                    <label>
                                        Type :
                                        <input class="text" type="text" id="filtre_type" aria-controls="DataTables_Table_0"/>
                                    </label>
                                </td>
                            </tr>
                        </table>


                    </div>
                    <div id="DataTables_Table_0_length" class="dataTables_length">
                        <button onclick="newDepartement()" class="btn btn-primary"><span class="icon16 cut-icon-plus white"></span>Nouveau Département</button>

                    </div>

                    <div id="list_departement">

                {% include 'GdsArticleBundle:Departement:pageList.html.twig' %}
                    </div>
                </div>
            </div>
        </div>
    </div><!-- End .box -->

</div><!-- End .span12 -->

</div><!-- End .row-fluid -->
<script>
    $('#filtre_nom').keyup(function() {
        goToPage('{{path(pagination.route)}}?type=ajax')
    })
    $('#filtre_ville').keyup(function() {
        goToPage('{{path(pagination.route)}}?type=ajax')
    })
    $('#filtre_type').keyup(function() {
        goToPage('{{path(pagination.route)}}?type=ajax')
    })
   
    function goToPage(url) {
        $.ajax({
            url: url,
            data: '&nom=' + $('#filtre_nom').val()+'&type_dep=' + $('#filtre_type').val()+'&ville=' + $('#filtre_ville').val(),
            success: function(data) {
                $('#list_departement').html(data)
            }
        })
    }
    function newDepartement(){
       $.ajax({
           url: '{{path('gds_departement_new')}}',
           success: function(data){
               $('#div_departement').html(data)
           }
       })
    }
    </script>

